﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;


namespace FinalTestMachine.View.Dispenser
{
    /// <summary>
    /// WndErrMeasureViewModel.xaml 的交互逻辑
    /// </summary>
    public partial class WndErrMeasureViewModel : Window
    {
        public WndErrMeasureViewModel()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 忽略本次称重
        /// </summary>
        public event Action DirectNextEvent;

        /// <summary>
        /// 重新称重
        /// </summary>
        public event Action ReWeightEvent;

        /// <summary>
        /// 清除错误
        /// </summary>
        public event Action ClearErrEvent;

        bool IsDealed = false;

        private void Btn_DirectNext_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                IsDealed = true;
                DirectNextEvent?.Invoke();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        private void Btn_ReWeight_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                IsDealed = true;
                ReWeightEvent?.Invoke();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }


        private void Btn_ClearErr_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ClearErrEvent?.Invoke();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }


        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                //tb_BaseValue.Text = MeasureWeightHelper.Cur.weightData.StandValue.ToString();
                //tb_LimitValue.Text = MeasureWeightHelper.Cur.weightData.D_threshold_Value.ToString();
                //tb_ResultValue.Text = MeasureWeightHelper.Cur.weightData.MeasureWeightNow.ToString();
                //tb_D_Value.Text = MeasureWeightHelper.Cur.weightData.D_WeightValue.ToString();


            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!IsDealed)
            {
                e.Cancel = true;
                MessageBox.Show(LanguageManager.LanguageSearchHelper.GetLanguage_UI("请选择处理方式!"));
            }
        }
    }
}
